/**
 * @file Square.cpp
 * 
 * This file contains the definitions of all the funcitons to manipulate the 
 * Square class.
 */
#include "Shape.hpp"
#include "Square.hpp"

/**
 * Default constructor
 */
Square::Square(){}

/**
 * Square constructor
 * @param name: x, y, size, and color - description: center point, size and color
 * given by the user.
 */
Square::Square( int x, int y, int size, COLORREF color ) : Shape( x, y, size, color )
{}

/**
 * Destructor
 */
Square::~Square(){}

/**
 * Returns true if coordinance of a point is inside the Square
 * @param name: x, y - description: coordinance given by the user.
 */
bool Square::contains( int X, int Y )
{
	setCorners();
	return (X >= left && X <= right && Y >= bottom && Y <= top);
}

/**
 * Draws a square inside the shape boundaries.
 * @param name: canvas - description: object passed by reference to 
 * specify how a square should be drawn.
 */
void Square::draw( Canvas& canvas )
{
	setCorners();
	canvas.drawRectangle( left, top, right, bottom, RGB( 0, 0, 0 ), color );
}

/**
 * Sets the corners of a square.
 */
void Square::setCorners()
{
	left = x - size / 2;
	right = x + size / 2;
	top = y + size / 2;
	bottom = y - size / 2;
}

